package com.example.Activity;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import com.example.ImageLoad.MyAdapter;
import android.app.Activity;
import android.content.Intent;

public class MainActivity extends Activity {

	private ListView listView;

	String[] images = new String[] { "http://img5.duitang.com/uploads/item/201601/14/20160114173345_sL5Z4.jpeg",
			"http://cdn.duitang.com/uploads/item/201505/29/20150529200613_T2cKW.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201510/14/20151014012341_W2ZxJ.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201601/30/20160130152952_kYQLc.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201601/17/20160117215909_Snasc.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201505/15/20150515135946_HiXL5.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201503/15/20150315150939_AWHRV.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201503/15/20150315150831_UAzs5.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201510/03/20151003113719_xSFVr.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201509/14/20150914093726_vZUnm.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201512/02/20151202223734_VYXAs.thumb.700_0.jpeg",
			"http://img5.duitang.com/uploads/item/201510/23/20151023142829_REhnx.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201601/12/20160112114858_HKXYU.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201507/20/20150720111137_v5uAc.thumb.700_0.jpeg",
			"http://img5.duitang.com/uploads/item/201510/28/20151028225404_i83aG.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201510/29/20151029125506_8wSjP.thumb.700_0.jpeg",
			"http://img5.duitang.com/uploads/item/201510/29/20151029125542_4KVaG.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201510/29/20151029125633_RtLuF.thumb.700_0.jpeg",
			"http://img5.duitang.com/uploads/item/201510/29/20151029125644_8r5ei.thumb.700_0.jpeg",
			"http://img5.duitang.com/uploads/item/201511/07/20151107094241_rvRsA.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201511/07/20151107094253_3eYQ4.thumb.700_0.jpeg",
			"http://img5.duitang.com/uploads/item/201511/07/20151107094219_aMEhy.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201511/07/20151107094149_RKnYQ.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201511/07/20151107094023_utLSi.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201511/07/20151107093953_ifZVn.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201510/29/20151029125339_ewcKm.thumb.700_0.jpeg",
			"http://img5.duitang.com/uploads/item/201502/19/20150219222212_NAAGW.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201507/06/20150706210524_Jf8GF.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201507/06/20150706210700_ktveY.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201507/06/20150706153158_3GTkh.thumb.700_0.jpeg",
			"http://img4.duitang.com/uploads/item/201512/28/20151228223521_yZCdU.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201408/22/20140822091708_PQYjz.thumb.700_0.png",
			"http://img4.duitang.com/uploads/item/201510/10/20151010185704_tkhvJ.thumb.700_0.jpeg",
			"http://cdn.duitang.com/uploads/item/201510/10/20151010185624_kjNUK.thumb.700_0.jpeg",
			"http://img5.duitang.com/uploads/item/201508/13/20150813191029_PYH4V.thumb.700_0.jpeg" };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		initView();
		initEvent();
	}

	private void initView() {
		listView = (ListView) findViewById(R.id.listview);
	}

	private void initEvent() {
		MyAdapter adapter = new MyAdapter(this, images);
		listView.setAdapter(adapter);
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(MainActivity.this, ImageDetailActivity.class);
				intent.putExtra("url", images[position]);
				startActivity(intent);
			}
		});
	}
}
